<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/7/17
 * Time: 17:14
 */

namespace app\common\model;


use think\Model;

class Category extends Model
{
    public function lists()
    {
        $list = Category::order("id ASC")->select()->toArray();
        $res = list_to_tree($list,'id','upid');
        return $res;
    }

    public function info($id, $field = true){
        /* 获取分类信息 */
        $map = array();
        if(is_numeric($id)){ //通过ID查询
            $map['id'] = $id;
        } else { //通过标识查询
            $map['name'] = $id;
        }
        return Category::field($field)->where($map)->find();
    }


}